package net.huashitong.supervision.task.controller;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.JqGrid;
import com.sirdc.modules.core.web.model.Message;
import com.sirdc.modules.sys.util.SysUserUtils;
import net.huashitong.supervision.insideDuCha.entity.InsideMainTaskEntity;
import net.huashitong.supervision.insideDuCha.filter.InsideMainTaskFilter;
import net.huashitong.supervision.task.entity.SMSLogEntity;
import net.huashitong.supervision.task.filter.SMSLogFilter;
import net.huashitong.supervision.task.service.SMSLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 短信列表
 */
@Controller
@RequestMapping(value = "/smslogs")
public class SMSLogCtrl  extends JsonBaseController {

    @Autowired
    private SMSLogService smsLogService;

    @Override
    protected String getView(String s) {
        return "/modules/task/sms/"+s;
    }
    @RequestMapping(value = "/logs")
    public String allTask(Model model){

        model.addAttribute("deptId", SysUserUtils.getDeptId());
        return getView("query");
    }

    @ResponseBody
    @RequestMapping(value = "/logs", method = RequestMethod.POST)
    public JqGrid initAllTasks(@ModelAttribute SMSLogFilter filter){


        List<SMSLogEntity> smsLog = smsLogService.getSmsLog(filter);


        return  coverJqGrid(filter,smsLog);
    }



}
